package com.yanqu.road.dao.impl.servercenter;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.HashSet;
import java.util.Set;

public class MiniGameConfigDaoImpl  extends TempDao {

    public  Set<Integer> getOpenMiniGame(int channelId) {
        ResultSet rs = null;
        CallableStatement call = null;
        Set<Integer> set = new HashSet<>();
        String sql = "select minGameId from t_s_mingame_start_channel_bind where channelId = ? and status = 1";
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(sql);
            call.setInt(1, channelId);
            rs = call.executeQuery();
            while (rs.next()) {
                int minGameId = rs.getInt("minGameId");
                set.add(minGameId);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            getDb().closeConnection(call, rs);
        }
        return set;
    }
}
